<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var names = [123,456,true,"张三","李四"];
        var users = new Array();  //var users = new array(5);
        users[0] = 12345;     //根据数组的下标进行赋值操作

        document.write(names[2]+"<br>");
        document.write(names.length+"<br>");
        document.write(users.length+"<br>");

        var users2 = new Array(9); 
        document.write(users2.length+"<br>");
        document.write(users2[0]+"<br>");

        var string = 'alei';  //字符串本身就是一组字符的集合
        for(var i=0; i<string.length;i++){
            document.write(string[i]+"<br>");
        }

        //数组的操作：求一组中给定的数字型数组中的最大值
        var numbers = [111,222,333,444,555,777,123,55];
        var maxnum = numbers[0];
        for(var j=0; j<numbers.length; j++){
            if(numbers[j]>maxnum){
                maxnum = numbers[j];
            }
        }
        document.write(numbers+"最大值为"+maxnum+"<br>");

        //不借助其他数组，数组反转
        var numbers = [111,222,333,444,555,777,123,55];
        for(var i=0;i<numbers.length/2; i++){
            var temp = numbers[i];
            numbers[i] = numbers[numbers.length-1-i];
            numbers[numbers.length-1-i] = temp;
        }
        document.write("反转后结果:" + numbers + "<br>");     


        //借助第二个数组，进行数组反转
        var one = [111,222,333,444,555,777,123,55];
        var two = new Array(one.length);
        for(var i = 0; i<one.length; i++){
            two[i] = one[one.length-i-1];
        }
        document.write("反转后结果:" + two + "<br>"); 
    </script>
</head>
<body>
    
</body>
</html>